<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="../include/tag.jsp" %>
<!DOCTYPE html>
<html lang="zh">
<head>
    <title>数据查看</title>
    <%@include file="../include/commonFile.jsp" %>
    <link rel="stylesheet" href="${ctx}/css/common/list.css">
    <link rel="stylesheet" href="${ctx}/css/common/table.css">
</head>
<body>
<%@include file="../include/header.jsp" %>

<div class="index-outside">
    <%@include file="../include/sidebar.jsp" %>
    <section>
        <div class="section-main">
            <%--转入--%>
            <div class="layui-tab layui-tab-brief mt20" lay-filter="type">
                <ul class="layui-tab-title">
                    <li class="" id="funding">众筹<span id="total_1" class="pl5">${crowdfundNum}</span>人</li>
                    <li class="" id="representing">联合发起<span id="total_0" class="pl5">${activity.representNum}</span>人</li>
                    <li class="" id="directPay">直接付款<span id="total_2" class="pl5">${directPayNum}</span>人</li>
                    <li class="layui-this" id="transfer">转入<span id="total_3" class="pl5">${transferNum}</span>人</li>
                </ul>
                <div class="layui-tab-content">
                    <form class="layui-form" action="${ctx}/activity/activity/zcShiftToPeopleList.do?id=${activity.id}" id="myForm" method="post">
                        <input type="hidden" name="pageNo" id="pageNo"/>
                        <div class="f-search-bar">
                            <div class="search-container">
                                <ul class="search-form-content">
                                    <li class="form-item"><label class="search-form-lable">众筹状态</label>
                                        <div class="check-btn-inner">
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),'','#myForm')" ${empty projectWithAuthor.isSuccess ? 'class="active"' : ''}>全部</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),0,'#myForm')" ${projectWithAuthor.isSuccess == 0 ? 'class="active"' : ''}>众筹中</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),1,'#myForm')" ${projectWithAuthor.isSuccess == 1 ? 'class="active"' : ''}>众筹成功</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),3,'#myForm')" ${projectWithAuthor.isSuccess == 3 ? 'class="active"' : ''}>退款中</a>
                                            <a href="javascript:void(0);" onclick="setTimeType($(this),4,'#myForm')" ${projectWithAuthor.isSuccess == 4 ? 'class="active"' : ''}>退款成功</a>
                                            <input type="hidden" name="isSuccess" value="${projectWithAuthor.isSuccess}"/>
                                        </div>
                                    </li>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item-inline"><label class="search-form-lable"
                                                                        style="text-indent: 13px;">众筹者</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorName" autocomplete="off"
                                                   class="layui-input"
                                                   value="${projectWithAuthor.authorName}"
                                                   placeholder="众筹者">
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label
                                            class="search-form-lable">联系电话</label>
                                        <div class="layui-input-inline">
                                            <input type="text" name="authorMobile" autocomplete="off"
                                                   class="layui-input"
                                                   value="${projectWithAuthor.authorMobile}"
                                                   placeholder="联系电话">
                                        </div>
                                    </li>
                                    <li class="form-item-inline"><label
                                            class="search-form-lable">排序方式</label>
                                        <div class="layui-input-inline">
                                            <select name="sort">
                                                <option value="0" ${projectWithAuthor.sort == 0 ? 'selected="selected"' : ''}>金额最多</option>
                                                <option value="1" ${projectWithAuthor.sort == 1 ? 'selected="selected"' : ''}>时间最近</option>
                                            </select>
                                        </div>
                                    </li>
                                </ul>
                                <ul class="search-form-content">
                                    <li class="form-item-inline"><label
                                            class="search-form-lable">筛选金额</label>
                                        <div class="layui-input-inline">
                                            <input type="number" name="amountGOE" autocomplete="off"
                                                   class="layui-input"
                                                   value="${projectWithAuthor.amountGOE}"
                                                   placeholder="最小金额">
                                        </div>-
                                        <div class="layui-input-inline">

                                            <input type="number" name="amountLOE" autocomplete="off"
                                                   class="layui-input"
                                                   value="${projectWithAuthor.amountLOE}"
                                                   placeholder="最大金额">
                                        </div>
                                    </li>
                                    <li class="form-item-inline">
                                        <div class="sub-btns">
                                            <a class="layui-btn layui-btn-danger"
                                               href="javascript:submitFunction('#myForm')">查询</a>
                                            <a class="layui-btn layui-btn-normal"
                                               href="javascript:resetFunction('#myForm')">重置</a>
                                        </div>
                                    </li>
                                </ul>
                            </div>
                        </div>
                    </form>
                    <form class="layui-form" action="${ctx}/activity/activity/zcShiftToPeopleListExport.do"
                          id="exportForm" method="post">
                        <input type="hidden" id="id" name="id" value="${activity.id}">
                    </form>
                    <div class="my-act-list-content">
                        <ul class="num">
                            <div class="l">
                                <li class="f16">共<span class="red">${page.totalCount}</span>数据</li>
                            </div>
                            <div class="r">
                                <li style="cursor: pointer;" class="r">
                                    <c:if test="${empty zipUrl}">
                                        <a class="layui-btn layui-btn-danger layui-btn-sm"
                                           href="javascript:txz.expireCheck('', function() { exportExcelData() })">导出EXCEL</a>
                                    </c:if>
                                    <c:if test="${not empty zipUrl}">
                                        <a class="layui-btn layui-btn-danger layui-btn-sm"
                                           href="javascript:txz.expireCheck('', function() { exportExcelData() })">重新生成EXCEL</a>
                                        <c:if test="${not empty zipUploadTime}">
                                            <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank"
                                               href="${zipUrl}"
                                               title="上次生成时间：${zipUploadTime}">点击下载</a>
                                        </c:if>
                                        <c:if test="${empty zipUploadTime}">
                                            <a class="layui-btn layui-btn-danger layui-btn-sm" target="_blank"
                                               href="${zipUrl}">点击下载</a>
                                        </c:if>
                                    </c:if>
                                </li>
                            </div>
                            <p class="cl"></p>
                        </ul>
                        <div class="cl">
                            <table class="layui-table">
                                <colgroup>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col>
                                    <col width="90px">
                                    <col>
                                    <col width="130px">
                                    <col width="90px">
                                    <col width="100px">
                                    <col width="90px">
                                    <col width="90px">
                                    <col width="90px">
                                    <col>
                                </colgroup>
                                <thead>
                                <tr>
                                    <th>众筹者</th>
                                    <th>渠道</th>
                                    <th>报名来源</th>
                                    <th>下级报名人数</th>
                                    <th>公司</th>
                                    <th>区域</th>
                                    <th>职务</th>
                                    <th>联系电话</th>
                                    <th>支持人数</th>
                                    <th>支持金额</th>
                                    <th>真实金额</th>
                                    <th>浏览量</th>
                                    <th>众筹状态</th>
                                    <th>操作</th>
                                </tr>
                                </thead>
                                <tbody>
                                <c:forEach var="directPay" items="${list}">
                                    <tr class="detail-content">
                                        <td class="table-member"
                                            onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.authorId}','400px','470px')">
                                            <div class="member-cell">
                                                <div class="member-logo common-img">
                                                    <img src="<c:if test="${ directPay.authorLogo!= null}">${directPay.authorLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1"><a class="blue"
                                                                                       title="${directPay.authorName}"
                                                                                       href="javascript:void(0);">${directPay.authorName}</a>
                                                </div>
                                            </div>
                                        </td>
                                        <td>
                                            <div class="ellipsis-1"
                                                 title="${directPay.publisher}">${directPay.publisher}</div>
                                        </td>
                                        <c:if test="${ not empty directPay.parentId}">
                                        <td class="table-member"
                                            onclick="openDialogShow('用户名片','${ctx}/system/member/memberView.do?id=${directPay.parentId}','400px','470px')">
                                            <div class="member-cell">
                                                <div class="member-logo common-img">
                                                    <img src="<c:if test="${directPay.parentLogo != null}">${directPay.parentLogo}?imageMogr2/auto-orient/crop/126x126</c:if>" alt="" onerror="txz.errImg(this)" onload="txz.imgLoad(this)">
                                                </div>
                                                <div class="member-name ellipsis-1"><a class="blue"
                                                                                       title="${directPay.parentName}"
                                                                                       href="javascript:void(0);">${directPay.parentName}</a>
                                                </div>
                                            </div>
                                        </td>
                                        </c:if>
                                        <c:if test="${ empty directPay.parentId}">
                                            <td></td>
                                        </c:if>
                                        <td>
                                            <a href="javascript:void(0);" class="blue ${directPay.childNum > 0 ? 'childNum' : ''} count-num"
                                               data-id="${directPay.authorId}" >${directPay.childNum}</a>
                                        </td>
                                        <td class="ellipsis-1">
                                                ${directPay.authorCompany}
                                        </td>
                                        <td>
                                                ${directPay.cityName}
                                        </td>
                                        <td>
                                                ${directPay.authorJobTitle}
                                        </td>
                                        <td>
                                                ${directPay.authorMobile}
                                        </td>
                                        <td>
                                            <a href="javascript:void(0);" class="blue ${directPay.actualAmount > 0||directPay.isSuccess == 4  ? 'favorerNum' : ''} count-num"
                                               data-id="${directPay.id}"
                                               data-name="${directPay.authorName}">${directPay.favorerNum}</a>

                                        </td>
                                        <td>
                                            <a href="javascript:void(0);"
                                               class="blue ${directPay.actualAmount > 0 ||directPay.isSuccess == 4 ? 'actualAmount' : ''} count-num"
                                               data-id="${directPay.id}"
                                               data-name="${directPay.authorName}"> ${directPay.actualAmount}</a>

                                        </td>
                                        <td>
                                            <c:if test="${empty directPay.realTimeAmount || null == directPay.realTimeAmount}">
                                                0.0
                                            </c:if>
                                            <c:if test="${ not empty directPay.realTimeAmount || null != directPay.realTimeAmount}">
                                                ${directPay.realTimeAmount}
                                            </c:if>
                                        </td>
                                        <td>
                                                ${directPay.viewNum}
                                        </td>
                                        <td>
                                            <c:if test="${directPay.isSuccess == 0}">
                                                <span>众筹中</span>
                                            </c:if>
                                            <c:if test="${directPay.isSuccess == 1}">
                                                <span>众筹成功</span>
                                            </c:if>
                                            <c:if test="${directPay.isSuccess == 2}">
                                                <span>众筹失败</span>
                                            </c:if>
                                            <c:if test="${directPay.isSuccess == 3}">
                                                <span>退款中</span>
                                            </c:if>
                                            <c:if test="${directPay.isSuccess == 4}">
                                                <span>退款成功</span>
                                            </c:if>
                                        </td>
                                        <td class="tb-opts">
                                            <div class="comm-opts">
                                                <a class="qr-btn"
                                                   href="javascript:txz.openQrDialog({
                                                               title:'扫码二维码可预览分享',
                                                               detailList:[
                                                                   {
                                                                   title:'众筹详情',
                                                                   url:'${directPay.qrCodeUrl }',
                                                                   link:'${directPay.url}'
                                                                   }
                                                               ]
                                                               })">二维码</a>
                                                <a href="javascript:openDialogShow('数据查看','${ctx}/crowdfund/support/chartView.do?projectId=${directPay.id}&targetId=${activity.id}','1050px','500px')"
                                                   target="_self">
                                                    数据查看
                                                </a>
<%--                                                <c:if test="${directPay.isSuccess != 1 && directPay.favorerNum > 0}">
                                                    <a href="javascript:openDialog('转移支持者','${ctx}/crowdfund/project/otherProject.do?projectId=${directPay.id}&targetUrl=dataTransfer','800px','500px')"
                                                       target="_self">
                                                        转移支持者
                                                    </a>
                                                </c:if>
                                                <c:set var="nowDate" value="<%=new Date()%>"></c:set>
                                                <c:if test="${activity.endTime < nowDate}">
                                                    <c:if test="${crowdfund.isSuccess == 1 && crowdfund.favorerNum > 0}">
                                                        <a href="javascript:openDialog('转移到下一个项目','${ctx}/crowdfund/project/otherSuccessfulProject.do?projectId=${directPay.id}&targetUrl=dataTransferZCSuccessful','800px','500px')"
                                                           target="_self">
                                                            转移到下一个项目
                                                        </a>
                                                    </c:if>
                                                </c:if>--%>
                                                <a href="javascript:revise('${directPay.id}')"
                                                   target="_self">
                                                    校正
                                                </a>
<%--                                                <c:if test="${directPay.actualAmount <= 0}">
                                                    <a href="javascript:txz.deleteObject('确定删除该众筹？', '${ctx}/crowdfund/project/delete.do?id=${directPay.id}');"
                                                       target="_self">
                                                        删除
                                                    </a>
                                                </c:if>--%>
                                            </div>

                                        </td>
                                    </tr>
                                </c:forEach>
                                </tbody>
                            </table>
                        </div>
                    </div>
                    <div id="page_content" class="page-container"></div>
                </div>
            </div>
        </div><%@include file="../include/footer.jsp" %>
    </section>
</div>

<script type="text/javascript" src="${ctx}/script/common/table_option.js"></script>
<script type="text/javascript" src="${ctx}/script/common/list.js"></script>

<script type="text/javascript">
    txz.initHeader({
        nav: [{
            name: '众筹项目',
            href: '${ctx}/activity/activity/zcActivityList.do'
        }, {
            name: '${activity.title}'
        }, {
            name: '数据查看',
            curr: true
        }],
        btns: [{
            type: 'back'
        }]
    });
    $(function () {
        //加载分页
        loadPageNew({
            elem: 'page_content',
            totalCount: '${page.totalCount}',
            limit: '${page.limit}',
            page: '${page.page}'
        });

        layui.use(['element'], function () {
            var element = layui.element;

            element.on('tab(type)', function (data) {
                if (data.index == 0) {
                    window.location.href = "${ctx}/activity/activity/zcCrowdfundList.do?id=${activity.id}";
                } else if (data.index == 1) {
                    window.location.href = "${ctx}/activity/activity/zcRepresentList.do?id=${activity.id}";
                } else if (data.index == 2) {
                    window.location.href = "${ctx}/activity/activity/zcDirectPayList.do?id=${activity.id}";
                }
                else if (data.index == 3) {
                    window.location.href = "${ctx}/activity/activity/zcShiftToPeopleList.do?id=${activity.id}";
                }
            });

            element.on('tab(zc)', function (data) {
                if (data.index == 0) {
                    $('#isSuccess').val('');
                    $('#myForm').submit();
                }
                else if (data.index == 1) {
                    $('#isSuccess').val('0');
                    $('#myForm').submit();
                }
                else if (data.index == 2) {
                    $('#isSuccess').val('1');
                    $('#myForm').submit();
                }
                else if (data.index == 3) {
                    $('#isSuccess').val('3');
                    $('#myForm').submit();
                }
                else if (data.index == 4) {
                    $('#isSuccess').val('4');
                    $('#myForm').submit();
                }
            });
        });

        $('.favorerNum').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/listForProjectId.do?id=${activity.id}&projectId=' + projectId + "&source=2";
        });

        $('.actualAmount').click(function () {
            var projectId = this.dataset.id;
            var name = this.dataset.name;
            window.location.href = '${ctx}/crowdfund/support/listForProjectId.do?id=${activity.id}&projectId=' + projectId + "&source=2";
        });

        $('.childNum').click(function () {
            var parentId = this.dataset.id;
            openDialogShow('下级报名人数', '${ctx}/crowdfund/project/childList.do?parentId=' + parentId + "&targetId=${activity.id}", '800px', '500px')
        });
    })

    function refund(id) {
        layer.confirm('确定要退款', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            $.post("${ctx}/crowdfund/project/refund.do", {
                id: id
            }, function (data) {
                if (data.success) {
                    util.layerAlertSuccess("退款成功", function () {
                        window.location.reload();
                    })
                } else {
                    util.layerAlertError("退款失败")
                }
            });
        });
    }

    function revise(id) {
        $.post("${ctx}/crowdfund/project/revise.do", {
            id: id
        }, function (data) {
            if (data.success) {
                util.layerAlertSuccess("校正成功", function () {
                    window.location.reload();
                })
            } else {
                util.layerAlertError("校正失败")
            }
        });
    }

    function openDialog(title, url, width, height, target) {
        layer.open({
            type: 2,
            area: [width, height],
            title: title,
            maxmin: true, //开启最大化最小化按钮
            content: url,
            btn: ['确定', '关闭'],
            yes: function (index, layero) {
                var body = layer.getChildFrame('body', index);
                var iframeWin = layero.find('iframe')[0]; //得到iframe页的窗口对象，执行iframe页的方法：iframeWin.method();
                var inputForm = body.find('#inputForm');
                var top_iframe;
                if (target) {
                    top_iframe = target;//如果指定了iframe，则在改frame中跳转
                } else {
                    top_iframe = '_parent';//获取当前active的tab的iframe
                }
                inputForm.attr("target", top_iframe);//表单提交成功后，从服务器返回的url在当前tab中展示

                if (iframeWin.contentWindow.doSubmit()) {
                    setTimeout(function () {
                        top.layer.close(index);
                    }, 100);//延时0.1秒，对应360 7.1版本bug

                    setTimeout(function () {
                        window.location.reload();
                    }, 200);
                }

            },
            cancel: function (index) {
            }
        });
    }

    function exportExcelData() {
        layer.confirm('确认要导出Excel吗?', {
            icon: 3,
            title: '系统提示'
        }, function (index) {
            //loading层
            var loadIndex = layer.load(1, {
                shade: [0.1, '#fff'] //0.1透明度的白色背景
            });
            $.post("${ctx}/activity/activity/zcShiftToPeopleListExport.do?id=${activity.id}", $("#myForm").serialize(), function (data) {
                console.log('start : ' + new Date().getTime());
                layer.close(loadIndex);
                if (data.success) {
                    util.layerAlertSuccess("正在导出中请耐心等待，稍后请点击下载按钮即可下载文件。")
                } else {
                    util.layerAlertError("操作失败");
                }
            });
            top.layer.close(index);
        });
    }

    util.initWebSocket(function (event) {
        console.log(event.data);
        console.log('end : ' + new Date().getTime());
        if (event.data) {
            util.layerAlertSuccess(event.data, function () {
                var title = "\"${activity.title}\"";
                var substr = event.data.substring(0, event.data.indexOf('众筹转入人员导出成功了'));
                if (title == substr) {
                    location.reload();
                }
            })
        }
    });
</script>
</body>
</html>
